using System;
using Csla;

namespace ENT.GP.Core.Autenticacion
{
    [Serializable]
    public class UsuarioCriterio : BusinessBase<UsuarioCriterio>
    {
        #region Business Methods

        private static PropertyInfo<int> RolIdProperty = RegisterProperty<int>(o => o.RolId, "Name");
        public int RolId
        {
            get { return GetProperty(RolIdProperty); }
            set { SetProperty(RolIdProperty, value); }
        }

        private static PropertyInfo<string> NombreProperty = RegisterProperty<string>(o => o.Nombre, "Name");
        public string Nombre
        {
            get { return GetProperty(NombreProperty); }
            set { SetProperty(NombreProperty, value); }
        }
        
        //Nuevo Id Empresa
        private static PropertyInfo<int> IDEmpresaProperty = RegisterProperty<int>(o => o.IDEmpresa, "Name");
        public int IDEmpresa
        {
            get { return GetProperty(IDEmpresaProperty); }
            set { SetProperty(IDEmpresaProperty, value); }
        }



        #endregion

        #region Validation Rules

        protected override void AddBusinessRules()
        {
            // TODO: add validation rules
            //ValidationRules.AddRule(RuleMethod, "");
        }

        #endregion

        #region Authorization Rules

        protected override void AddAuthorizationRules()
        {
            // TODO: add authorization rules
            //AuthorizationRules.AllowWrite("Name", "Role");
        }

        private static void AddObjectAuthorizationRules()
        {
            // TODO: add authorization rules
            //AuthorizationRules.AllowEdit(typeof(UsuarioCriterio), "Role");
        }

        #endregion

        #region Factory Methods

        public static UsuarioCriterio NewUsuarioCriterioRoot()
        {
            return DataPortal.Create<UsuarioCriterio>();
        }

        public static UsuarioCriterio GetUsuarioCriterio(int id)
        {
            return DataPortal.Fetch<UsuarioCriterio>(
              new SingleCriteria<UsuarioCriterio, int>(id));
        }

        

        private UsuarioCriterio()
        { /* Require use of factory methods */ }

        #endregion

        
    }
}
